<html>
  <head>
    <title>�ޱ����ĵ�</title>
    <script src="joygo_des.js"></script>
    <script>
      var myDate = new Date();
      alert(myDate.getTime());
      //end-------------------------------------------------------------------------------------------------------------

      function enString() {
        var data = desform.endata.value;
        var key1 = desform.keydata1.value;
        var key2 = desform.keydata2.value;
        var key3 = desform.keydata3.value;
        var enchex = strEnc(data, key1, key2, key3);
        entext.innerText = enchex;
        encleng.innerText = enchex.length;
        desform.dedata.value = enchex;
      }
      function deString() {
        var data = desform.dedata.value;
        var key1 = desform.keydata1.value;
        var key2 = desform.keydata2.value;
        var key3 = desform.keydata3.value;
        var dechex = strDec(data, key1, key2, key3);
        detext.innerText = dechex;
      }

      function test() {
        var msg = 'abcdefgh';
        var bt = strToBt(msg);

        var key = '12345678';
        var keyB = strToBt(key);

        var encByte = enc(bt, keyB);

        var enchex = bt64ToHex(encByte);
        endata.value = enchex;

        var encStr = hexToBt64(enchex);
        alert('encStr=' + encStr);
        var eByte = new Array();
        for (m = 0; m < encStr.length; m++) {
          eByte[m] = parseInt(encStr.substring(m, m + 1));
        }
        var decbyte = dec(eByte, keyB);
        var decmsg = byteToString(decbyte);
        alert('decbyte=' + decbyte);
        alert('decmsg=' + decmsg);
      }
    </script>
  </head>

  <body>
    <center>
      <form name="desform" method="post" action="des.jsp">
        <table>
          <tr>
            <td align="right">��һ����Կ</td>
            <td align="left"><input type="text" name="keydata1" size="50" /><font color="red">*</font></td>
          </tr>
          <tr>
            <td align="right">�ڶ�����Կ</td>
            <td align="left">
              <input type="text" name="keydata2" size="50" />
            </td>
          </tr>
          <tr>
            <td align="right">��������Կ</td>
            <td align="left">
              <input type="text" name="keydata3" size="50" />
            </td>
          </tr>
          <tr>
            <td align="right">Ҫ���ܵ�����:</td>
            <td align="left">
              <input type="text" name="endata" size="50" />
              <input type="button" value="DES����" onClick="enString()" />
            </td>
          </tr>
          <tr>
            <td align="right">���ܺ������:</td>
            <td align="left"><span id="entext"></span><br /></td>
          </tr>
          <tr>
            <td align="right">���ĳ��ȣ�</td>
            <td align="left">
              <span id="encleng"></span>
            </td>
          </tr>
          <tr>
            <td align="right">Ҫ���ܵ�����:</td>
            <td align="left">
              <input type="text" name="dedata" size="50" />
              <input type="button" value="DES����" onClick="deString()" />
            </td>
          </tr>
          <tr>
            <td align="right">���ܵ�����:</td>
            <td align="left">
              <span id="detext"></span>
            </td>
          </tr>
        </table>
      </form>
    </center>
  </body>
</html>
